//
//  IManager+ModulePersonCenter.m
//  RocketProject
//
//  Created by chen jiedan on 13-9-18.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "IManager+ModulePersonCenter.h"
#import "RequestUtlity.h"
#import "NetUrlDefines.h"
#import "FrameworkRelativeDefines.h"
#import "GloableEngineService.h"
#import "NSString+NSString_Ex_.h"
#import "RCUserDataModel.h"
#import "RCDianpingListDataModel.h"
#import "RCMyCheckInListDataModel.h"
#import "RCMyOrderListDataModel.h"
#import "RCMerchantsListDataModel.h"
#import "RCFansFollowerListDataModel.h"
#import "RCMyScoreListDataModel.h"
#import "RCMyPhotosListDataModel.h"
#import "RCScoreListDataModel.h"
#import "RCServerCheckPhotoListModel.h"
#import "RCMessageListDataModel.h"
#import "RCBaseServerDataModel.h"
@implementation IManager (ModulePersonCenter)

-(int64_t)requestPersonInfo:(NSString *)userID WithDelegte:(id<IManagerDelegate>)delegate
{
    
    NSString *bduss = [[GloableEngineService sharedInstance] bduss];
    if ( userID == nil && [NSString stringIsNullOrEmpty:bduss]) {
        //查看个人信息
        return kInvalidID;
    }
    
    NSString *urlSuffix = nil;
    if (userID == nil) {
       urlSuffix = [NSString stringWithFormat:kRCPersonInfoCount,bduss];
    }else{
        urlSuffix = [NSString stringWithFormat:kRCOtherPersonInfoPrefix,userID,bduss];
    }
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
    
//    NSDictionary *userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"PersonInfoCenter"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    

    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCUserProfileModel class]
                                                     withDataDelegate:delegate];

    
    
}


-(int64_t)requestFansListData:(FansListVCType)type
                       withPn:(NSInteger)pn
                       withRn:(NSInteger)rn
                   withUserID:(NSString *)userID
                   withStatus:(NSString *)orderType
                  withDelegte:(id<IManagerDelegate>)delegate
{
    
    NSString *bduss = [[GloableEngineService sharedInstance] bduss];
    NSString *shopBduss = [[GloableEngineService sharedInstance] shopBduss];
    NSString *shopID = [[GloableEngineService sharedInstance] shopID];

    if (userID == nil && [NSString stringIsNullOrEmpty:bduss]) {
        return kInvalidID;
    }
    
    NSString *urlSuffix = nil;
    Class parseClass = nil;
    NSDictionary *userInfo = nil;
    if (type == FansListVCType_dianping ) {
        if (userID == nil) {
            urlSuffix = [NSString stringWithFormat:kRCMyDianpingPrefix,bduss,pn,rn];
        }else{
            urlSuffix = [NSString stringWithFormat:kRCOtherDianpingPrefix,userID,pn,rn];
        }
        parseClass = [RCDianpingListDataModel class];
//        userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"DianpingJson"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    }else if (type == FansListVCType_myCheckIn){
        parseClass = [RCMyCheckInListDataModel class];
        if (userID == nil) {
            urlSuffix = [NSString stringWithFormat:kRCMyCheckInPrefix,bduss,pn,rn];

        }else{
            urlSuffix = [NSString stringWithFormat:kRCOtherCheckInPrefix,userID,pn,rn];
        }
//        userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"MycheckIn"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    }else if (type == FansListVCType_myOrders){
        parseClass = [RCMyOrderListDataModel class];
        urlSuffix = [NSString stringWithFormat:kRCMyOrderPrefix,bduss,orderType,pn,rn];
//        userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"MyOrderList"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    }else if (type == FansListVCType_myCollect){
        parseClass = [RCMerchantsListDataModel class];
        if (userID == nil) {
            urlSuffix = [NSString stringWithFormat:kRCMyCollectPrefix,bduss,pn,rn];
        }else{
            urlSuffix = [NSString stringWithFormat:kRCOtherCollectPrefix,userID,pn,rn];

        }
//        userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"MyCollectJson"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    }else if (type == FansListVCType_fans){
        parseClass = [RCFansFollowerListDataModel class];
        if (userID == nil) {
            urlSuffix = [NSString stringWithFormat:kRCMyFansListPrefix,bduss,pn,rn];
        }else{
            urlSuffix = [NSString stringWithFormat:kRCOtherFansListPrefix,userID,pn,rn];
        }
//        userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"MyFansList"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    }else if (type == FansListVCType_follow){
        parseClass = [RCFansFollowerListDataModel class];
        if (userID == nil) {
            urlSuffix = [NSString stringWithFormat:kRCMyFollowListPrefix,bduss,pn,rn];
        }else{
            urlSuffix = [NSString stringWithFormat:kRCOtherFollowListPrefix,userID,pn,rn];

        }
//        userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"MyFollowList"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    }else if (type == FansListVCType_photo){
        parseClass = [RCMyPhotosListDataModel class];
        if (userID == nil) {
            urlSuffix = [NSString stringWithFormat:kRCMyPhotoPrefix,bduss,pn,rn];
        }else{
            urlSuffix = [NSString stringWithFormat:kRCOtherPhotoPrefix,userID,pn,rn];
        }
//        userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"MyPhotosJson"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    }else if (type == FansListVCType_Score){
        parseClass = [RCScoreListDataModel class];
        urlSuffix = [NSString stringWithFormat:kRCScoreListPrefix,pn,rn];
//        userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"ScoreListJson"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    }else if (type == FansListVCType_photoCheck){
        parseClass = [RCServerCheckPhotoListModel class];
        urlSuffix = [NSString stringWithFormat:kRCWaitingCheckPicsListPrefix,shopBduss,shopID,pn,rn];
//        userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"PhotoCheckListJson"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    }else if (type == FansListVCType_mailBox){
        parseClass = [RCMessageListDataModel class];
        if (userID == nil) {
            urlSuffix = [NSString stringWithFormat:kRCMyMailListPrefix,bduss,pn,rn];
            
        }
        //        userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"MycheckIn"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    }
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
    

    
    
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:userInfo
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:parseClass
                                                     withDataDelegate:delegate];
}


-(int64_t)requestUserScorewithPn:(NSInteger)pn withRn:(NSInteger)rn withDelegte:(id<IManagerDelegate>)delegate
{
    NSString *bduss = [[GloableEngineService sharedInstance] bduss];
    if ([NSString stringIsNullOrEmpty:bduss]) {
        return kInvalidID;
    }
    
    NSString *urlSuffix = [NSString stringWithFormat:kRCUserScorePrefix,bduss,pn,rn];
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
    
//    NSDictionary *userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"MyScoreJson"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    
    
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCMyScoreListDataModel class]
                                                     withDataDelegate:delegate];

    
}


-(int64_t)requestFollowOrCancel:(NSString *)userID withStatus:(NSInteger)status WithDelegte:(id<IManagerDelegate>)delegate
{
    NSString *bduss = [[GloableEngineService sharedInstance] bduss];
    if ( userID == nil && [NSString stringIsNullOrEmpty:bduss]) {
        //查看个人信息
        return kInvalidID;
    }
    
    NSString *urlSuffix = nil;

        urlSuffix = [NSString stringWithFormat:kRCPersonFollowOrCancelPrefix,userID,bduss,status];
    
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
    
    //    NSDictionary *userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"PersonInfoCenter"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    
    
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCBaseServerDataModel class]
                                                     withDataDelegate:delegate];

}


//1是男 2是女
-(int64_t)requestEditUserInfo:(NSString *)userName
                      withSex:(NSInteger)status
                 withLiveCity:(NSInteger)cityID
                  WithDelegte:(id<IManagerDelegate>)delegate
{
    
    NSString *bduss = [[GloableEngineService sharedInstance] bduss];
    if ( userName == nil && [NSString stringIsNullOrEmpty:bduss]) {
        //查看个人信息
        return kInvalidID;
    }
    
    NSString *urlSuffix = nil;
    
    urlSuffix = [NSString stringWithFormat:kRCPersonEditInfoPrefix,userName,bduss,status,cityID];
    
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
    
    //    NSDictionary *userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"PersonInfoCenter"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    
    
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCBaseServerDataModel class]
                                                     withDataDelegate:delegate];
}

@end
